import type { CartItemType } from '@/types/cart'
import { http } from '@/utils/http'

export const addCartHttp = (data:{
  skuId:string,count:number
})=>{
  return http({
    url:'/member/cart',
    method:'POST',
    data
  })
}
/**
 * 获取购物车列表
 * @returns 
 */
export const getCartListHttp = ()=>{
  return http<CartItemType[]>({
    url:'/member/cart',
    method:'GET',
  })
}
/**
 * 删除cart的商品
 * @returns 
 */
export const deleteGoodsHttp = (data:{ids:string[]})=>{
  return http({
    url:'/member/cart',
    method:'DELETE',
    data
  })
}

/**
 * 修改商品
 * @param skuId 
 * @param data 
 * @returns 
 */
export const updateCartGoodsNumberHttp = (
  skuId:string,
  data:{
    selected?:boolean,
    count?:number
}
)=>{
  return http({
    url:`/member/cart/${skuId}`,
    method:'PUT',
    data,
  })
}
